#include "test.h"
#include "namespace.h"

static int
test_desc_create()
{
    LSUP_Term *terms1[] = {
        LSUP_iriref_new ("usn:s:1", NULL),
        LSUP_iriref_new ("usn:s:2", NULL),
        LSUP_iriref_new ("usn:p:1", NULL),
        LSUP_iriref_new ("usn:p:2", NULL),
        LSUP_iriref_new ("usn:o:1", NULL),
        LSUP_iriref_new ("usn:o:2", NULL),
    };
    LSUP_Term *terms2[] = {
        LSUP_iriref_new ("usn:s:10", NULL),
        LSUP_iriref_new ("usn:s:20", NULL),
        LSUP_iriref_new ("usn:p:10", NULL),
        LSUP_iriref_new ("usn:p:20", NULL),
        LSUP_iriref_new ("usn:o:10", NULL),
        LSUP_iriref_new ("usn:o:20", NULL),
    };

    LSUP_Triple trp1[] = {
        {terms1[0], terms1[2], terms1[4]},
        {terms1[0], terms1[3], terms1[4]},
        {terms1[0], terms1[3], terms1[5]},
        {terms1[1], terms1[2], terms1[4]},
        {NULL}
    };
    LSUP_Triple trp2[] = {
        {terms2[0], terms2[2], terms2[4]},
        {terms2[0], terms2[3], terms2[4]},
        {terms2[0], terms2[3], terms2[5]},
        {terms2[1], terms2[2], terms2[4]},
        {NULL}
    };

    LSUP_Graph *gr1 = LSUP_graph_new (
            LSUP_iriref_new ("#usr1", NULL), LSUP_STORE_MEM);
    LSUP_graph_add (gr1, trp1, NULL);
    LSUP_Graph *gr2 = LSUP_graph_new (
            LSUP_iriref_new ("#usr2", NULL), LSUP_STORE_MEM);
    LSUP_graph_add (gr2, trp2, NULL);

    LSUP_Graph *data[] = {gr1, gr2, NULL};
    LSR_Desc *rsrc;
    EXPECT_PASS (LSR_desc_new_multi (data, &rsrc));

    // Free input handles before using the resource to ensure that these
    // pointers are not being referenced by the resource.
    LSUP_graph_free (gr1);
    LSUP_graph_free (gr2);

    for (int i = 0; i < 6; i++) {
        LSUP_term_free (terms1[i]);
        LSUP_term_free (terms2[i]);
    }

    // TODO more action

    // Store for next test before freeing.
    EXPECT_PASS (LSR_desc_store (rsrc));

    LSR_desc_free (rsrc);

    return 0;
}


static int
test_desc_get ()
{
    return 0;
}

int desc_tests()
{
    RUN (test_desc_create);
    RUN (test_desc_get);
    return 0;
}
